from itertools import accumulate

T = int(input())
nums = []
for _ in range(T):
    nums.append(int(input()))
limit = max(nums)

# 线性筛
is_prime = [True] * (limit + 1)
primes = []
euler = [1] * (limit + 1)
for i in range(2, limit + 1):
    if is_prime[i]:
        primes.append(i)
        euler[i] = i - 1
    for prime in primes:
        if i * prime > limit: break
        is_prime[i * prime] = False
        euler[i * prime] = euler[prime] * euler[i]
        if i % prime == 0:
            euler[i * prime] = euler[i] * prime
            break
euler[0] = 0
prefix = list(accumulate(euler))
for num in nums:
    print(prefix[num])
